02 / 07

What are the properties of an HTML element?

Properties of an HTML Element

In HTML, every element is represented as an object in the Document Object Model (DOM). These objects have properties, which are values that define the state and behavior of the element. Properties are different from attributes: attributes are defined in the HTML markup, while properties are the current values that JavaScript sees when working with the DOM.

Example: Accessing Properties with JavaScript
Common Properties of HTML Elements
  1. 1

    id – reflects the element's id attribute

  2. 2

    className – reflects the element's class attribute

  3. 3

    innerHTML – represents the HTML content inside the element

  4. 4

    textContent – represents only the text content

  5. 5

    value – for form elements (input, textarea, select)

  6. 6

    checked – for checkboxes and radio buttons

  7. 7

    disabled – indicates if the element is disabled

  8. 8

    style – allows access to inline styles via JavaScript